package com.ssy.lingxi.report.repository.settleaccount;

import com.ssy.lingxi.report.entity.settleaccount.MemberProductionNoticeSettlementDO;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 会员生产通知单结算
 * @author 伍将
 * @date 2020/10/26
 * @version 2.0.0
 */
public interface MemberProductionNoticeSettlementRepository extends JpaRepository<MemberProductionNoticeSettlementDO, Long>, JpaSpecificationExecutor<MemberProductionNoticeSettlementDO> {

    /**
     * 根据结算数据id删除生成通知单结算
     * @author 伍将
     * @date 2020/11/14
     * @param settlementId:
     * @return void
     **/
    @Transactional
    void deleteAllBySettlementId(Long settlementId);

    /**
     * 根据条件按照订单时间倒序排列取一条数据
     * @author 伍将
     * @date 2020/11/13
     * @param memberId:
     * @param roleId:
     * @param payMemberId:
     * @param payRoleId:
     * @return com.ssy.lingxi.report.entity.settleaccount.MemberProductionNoticeSettlementDO
     **/
    MemberProductionNoticeSettlementDO findFirstByMemberIdAndRoleIdAndPayMemberIdAndPayRoleIdOrderByReceiveTimeDesc(Long memberId, Long roleId, Long payMemberId, Long payRoleId);

    @Transactional
    void deleteAllBySettlementIdIn(List<Long> idList);
}
